package com.campus.controller;

import com.campus.common.Result;
import com.campus.domain.Dto.TeacherAddDto;
import com.campus.service.ITeacherService;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/teacher")
@Slf4j
public class TeacherController {

    @Autowired
    private ITeacherService teacherService;

    @PostMapping("/add")
    public Result addTeacher(@RequestBody @Validated TeacherAddDto teacherAddDto){
        int rs = teacherService.addTeacher(teacherAddDto);
        return rs == 1 ? Result.success() : Result.error();
    }

    @GetMapping("/select/{id}")
    public Result selectTeacherById(@PathVariable Long id){
        return Result.success(teacherService.selectById(id));
    }
}
